<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>词多多代理商平台</title>
    <include file="Index:header"/>
    <!----自动提示的input引入文件开始---------->
    <link rel="stylesheet" href="__PUBLIC__/css/textext.core.css" type="text/css" />
    <link rel="stylesheet" href="__PUBLIC__/css/textext.plugin.autocomplete.css" type="text/css" />
    <link rel="stylesheet" href="__PUBLIC__/css/textext.plugin.prompt.css" type="text/css" />
    <script src="__PUBLIC__/js/textext.core.js" type="text/javascript" charset="utf-8"></script>
    <script src="__PUBLIC__/js/textext.plugin.autocomplete.js" type="text/javascript" charset="utf-8"></script>
    <script src="__PUBLIC__/js/textext.plugin.prompt.js" type="text/javascript" charset="utf-8"></script>
    <!----自动提示的input引入文件结束---------->
    <script type="text/javascript">
        $(function(){
            $(".help-side dl dd:eq(2)").addClass('cur');
        })
        $(function(){
            $("#top #topcon .nav li:eq(2)").addClass('cur');
        })
    </script>
    <script src="__PUBLIC__/js/main.js" type="text/javascript" charset="UTF-8"></script>
</head>

<body>
    <include file="Index:top"/>
    <div id="main">
        <include file="Site:left"/>
        <div id="main_right" class="container">
            <div class="title">所有关键词</div>
            <div id="infotab" class="container mt10">
                <ul class="tb cl">
                <if condition="$_GET['status'] eq 'off'">
                    <li>
                        <a href="{:U('site_keyword_all')}">开启状态</a>
                    </li>
                    <li class="a">
                        <a href="{:U('site_keyword_all?status=off')}">暂停状态</a>
                    </li>
                <else/>
                    <li class="a">
                        <a href="{:U('site_keyword_all')}">开启状态</a>
                    </li>
                    <li>
                        <a href="{:U('site_keyword_all?status=off')}">暂停状态</a>
                    </li>
                </if>
                </ul>
                <div class="container mr10 ml10" id="infotab">
                <table class="tableStyle mt10 mb10">
                    <tr>
                        <td width="60px" style="padding-left: 30px;">用户名</td>
                        <td>
                            <input id="textarea" type="text" name="name" class="input" style="width:150px; z-index:100;"  onkeydown="enterPress(event)"/>
                        </td>
                        <td width="40px" style="padding-left: 170px;">站点</td>
                        <td>
                            <div id="domain" class="dropdown" tabIndex="1">
                                <select name="domain" style="height:30px;width:150px;" id="site">
                                    <option value="">请选择站点</option>
                                </select>
                            </div>
                        </td>
                        <if condition="$_GET['status'] eq 'off'">
                        <td style="padding-left: 20px;">
                            <input class="button_s green" type="submit" name="button" id="button" onclick="query1();" value="查&nbsp;&nbsp;询" />
                        </td>
                        <else/>
                        <td style="padding-left: 20px;">
                            <input class="button_s green" type="submit" name="button" id="button" onclick="query();" value="查&nbsp;&nbsp;询" />
                        </td>
                        </if>
                    </tr>
                </table>
                </div>
                <table class="table mr10 ml10" cellpadding=4 width="97%">
                    <tr style="border-bottom: 2px solid #eee;">
                        <th>关键词</th>
                        <th>站点</th>
                        <th>用户名</th>
                        <th>总价格(元)</th>
<!--                         <th width="19%">搜索引擎</th> -->
                        <th>操作</th>
                    </tr>

                    <tbody id="tbody">
                        <volist name="key_arr" id="vo">
                            <tr>
                                <td>{$vo['Keyword']}</td>
                                <td>{$vo['Website']}</td>
                                <td>{$vo['Username']}</td>
                                <td style="padding-left:20px">{$vo['Price']}</td>
<!--                                 <td style="padding-left:20px">{$vo['yinqing']}</td> -->
                                <td>
                                    <div class="menubox">
                                        <div class="mainmenu">
                                            <div class="category">
                                                <span class="tit">操作选项</span>
                                                <ul class="submenu">
                                                    <li>
                                                        <a href="javascript:void(0);" onclick="edit({$vo['id']});">
                                                            <span class='ico ico_application_edit'></span>
                                                            修 改
                                                        </a>
                                                    </li>
                                                    <if condition="$vo['Status'] eq ON">
                                                    <li>
                                                        <a href="javascript:void(0)" onclick="pause('__URL__/keyword_stop',{$vo['id']});">
                                                            <span class="ico ico_control_stop_blue"></span>
                                                            暂 停
                                                        </a>
                                                    </li>
                                                    <else/>
                                                    <li>
                                                        <a href="javascript:void(0)" onclick="start('__URL__/keyword_start',{$vo['id']});">
                                                            <span class="ico ico_control_play_blue"></span>
                                                            开 启
                                                        </a>
                                                    </li>
                                                    </if>                                                    
                                                    <li>
                                                        <a href="javascript:void(0);" onclick="del('__URL__/keyword_del',{$vo['id']});">
                                                            <span class='ico ico_cross'></span>
                                                            删 除
                                                        </a>
                                                    </li>
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                        </volist>
                    </tbody>
                </table>
                <div class="mt10">
                    <div class="page_list">
                        <div class="p_l">{$pageshow}</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <include file="Index:footer"/>
    <script>

        function usersite(){
            userName=$("#textarea").val();
            if(userName==""){
                msgwarn("如要查询请先输入用户名");
                return false;
            }
            get_url = "__APP__/User/usersites";
            $.ajax({
                url:get_url,
                type:'POST',
                data:{'userName':userName},
                cache:false,
                dataType:"json",
                success:function(data){
                    if(data.status =='true'){
                        $("#site option:gt(0)").remove();
                        $.each(data,function(n,value){
                            if(value!='true'){
                                $("#site").append("<option value="+value+">"+value+"</option>");
                            }
                        });
                    }else{
                        msgwarn(data.Msg);
                    }
                }
            });
        }
        $("#textarea").blur(function(){
            setTimeout("usersite()",200);
        });

        function enterPress(e) {
            if (e.keyCode == 13) {
                setTimeout("usersite()",100);
            }
        }

        function query(){
            userName=$("#textarea").val();
            site = $(".dropselectbox h4").text();

            if(userName==""){
                msgwarn("请填写用户名");
                return false;
            }

            if(site==""){
                msgwarn("请选择站点");
                return false;
            }

            window.location="__URL__/site_keyword_all?userName="+userName+"&site="+site;
        }

        function query1(){
            userName=$("#textarea").val();
            site = $(".dropselectbox h4").text();

            if(userName==""){
                msgwarn("请填写用户名");
                return false;
            }

            if(site==""){
                msgwarn("请选择站点");
                return false;
            }

            window.location="__URL__/site_keyword_all?status=off&userName="+userName+"&site="+site;
        }

        $(function() {
            $("#domain").sSelect();
        });

        function edit(id) {
            art.dialog.open('__URL__/site_keyword_edit/id/'+id, {
                title: '修改关键词',
                lock: 'true',
                close:function(){
                    parent.location.reload();
                }
            });
        }

        function hash(str, hashSize)
        
            {
                var result = 0;
                for(var i = 0; i < str.length; i++)
                    result += str.charCodeAt(i) + 31 * result;
                return result % hashSize;
            }

            $('#textarea')
                .textext({
                    plugins : 'autocomplete',
                    autocomplete : {
                        dropdownMaxHeight : '200px',

                        render : function(suggestion)
                        {
                            var icons = 'exclamation feed house information lock'.split(/ /g),
                                    icon  = icons[hash(suggestion, icons.length)];
                            return  suggestion
                        }
                    }
                })
                .bind('getSuggestions', function(e, data)
                {
                    var list = [{$username}
                            ],
                            textext = $(e.target).textext()[0],
                            query = (data ? data.query : '') || '';

                    $(this).trigger(
                            'setSuggestions',
                            { result : textext.itemManager().filter(list, query) }
                );
            });        
    </script>
</body>

</html>